package com.xc.ezplan.admin.controller;

import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.xc.ezplan.admin.entity.AdminTencentContent;
import com.xc.ezplan.admin.service.AdminTencentContentService;
import com.xc.ezplan.admin.vo.AdminTencentContentVo;
import com.xc.ezplan.core.base.BaseSearchBody;
import com.xc.ezplan.core.base.EzResult;
import com.xc.ezplan.log.annotation.Log;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

/**
 * @author lixingchen
 * @date 2022/12/07
 * @description 腾讯云存储
 */
@RestController
@RequestMapping("/tencent/content")
@Api(tags = "腾讯云存储")
@RequiredArgsConstructor
public class AdminTencentContentController {
    private final AdminTencentContentService adminTencentContentService;

    @Log("上传腾讯云文件")
    @ApiOperation("上传腾讯云文件")
    @PostMapping
    @SaCheckPermission("tencent.upload")
    public EzResult<Object> uploadContent(@RequestBody MultipartFile file,@RequestParam Long configId) {
        adminTencentContentService.uploadContent(file,configId);
        return EzResult.ok();
    }

    @Log("删除腾讯云文件")
    @ApiOperation("删除腾讯云文件")
    @DeleteMapping
    @SaCheckPermission("tencent.delete")
    public EzResult<Object> deleteContent(@RequestBody List<Long> ids,@RequestParam Long configId) {
        adminTencentContentService.deleteContent(ids,configId);
        return EzResult.ok();
    }

    @Log("修改腾讯云文件")
    @ApiOperation("修改腾讯云文件")
    @PutMapping
    public EzResult<Object> updateContent(@RequestBody AdminTencentContentVo adminTencentContentVo) {
        adminTencentContentService.updateContent(adminTencentContentVo);
        return EzResult.ok();
    }

    @Log("按条件查询配置")
    @ApiOperation("按条件查询配置")
    @PostMapping("/page")
    public EzResult<Object> pageQueryContent(@RequestBody BaseSearchBody<AdminTencentContent> baseSearchBody) {
        return EzResult.ok(adminTencentContentService.pageQueryContent(baseSearchBody));
    }

}
